using System;
using System.Data;

using MettleSystems.dashCommerce.Core;
using OpenNetCommerce.Localization;
using MettleSystems.dashCommerce.Store;

namespace MettleSystems.dashCommerce.Web.admin {
  public partial class trackinglogs : MettleSystems.dashCommerce.Controls.AdminPage {

    #region Page Events

    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e) {
      try {
        SetTrackingLogsProperties();
        LoadCategoryBrowsingLog();
        LoadProductBrowsingLog();
      }
      catch (Exception ex) {
        Logger.Error(typeof(trackinglogs).Name + ".Page_Load", ex);
        Master.MessageCenter.DisplayCriticalMessage(ex.Message);
      }
    }


    #endregion

    #region Methods

    #region Private

    /// <summary>
    /// Sets the tracking logs properties.
    /// </summary>
    private void SetTrackingLogsProperties() {
      //this.Title = LocalizationUtility.GetText("titleTrackingLogs");
    }

    /// <summary>
    /// Loads the product browsing log.
    /// </summary>
    private void LoadProductBrowsingLog() {
      DataSet dsProducts = new BrowsingLogController().FetchProductBrowsingLog();
      dgProducts.DataSource = dsProducts;
      dgProducts.Columns[0].HeaderText = LocalizationUtility.GetText("hdrHits");
      dgProducts.Columns[1].HeaderText = LocalizationUtility.GetText("hdrName");
      dgProducts.DataBind();
    }

    /// <summary>
    /// Loads the category browsing log.
    /// </summary>
    private void LoadCategoryBrowsingLog() {
      DataSet dsCategories = new BrowsingLogController().FetchCategoryBrowsingLog();
      dgCategory.DataSource = dsCategories;
      dgCategory.Columns[0].HeaderText = LocalizationUtility.GetText("hdrHits");
      dgCategory.Columns[1].HeaderText = LocalizationUtility.GetText("hdrName");
      dgCategory.DataBind();
    }

    #endregion

    #endregion

  }
}
